package com.lzkj.baotouhousingfund.webview;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.coderc.library.view.statusbar.StatusBarUtil;
import com.lzkj.baotouhousingfund.R;
import com.lzkj.baotouhousingfund.app.App;


/**
 * @author Chengs
 * @ClassName: WebViewActivity
 * @Description: WebView封装
 * @date 2018/1/13 14:23
 */
public class WebViewActivity extends BaseWebActivity {

    // title
    private String mTitle;
    // 网页链接
    private String mUrl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        getIntentData();
        super.onCreate(savedInstanceState);
        App.getInstance().addActivity(this);
        StatusBarUtil.setColor(this, getResources().getColor(R.color.colorTheme), 0);
    }

    private void getIntentData() {
        if (getIntent() != null) {
            mTitle = getIntent().getStringExtra("mTitle");
            mUrl = getIntent().getStringExtra("mUrl");
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        App.getInstance().removeActivity(this);
    }

    @Override
    public String getWebTitle() {
        return mTitle;
    }

    @Override
    public String getUrl() {
        return mUrl;
    }

    /**
     * 打开网页:
     *
     * @param mContext 上下文
     * @param mUrl     要加载的网页url
     * @param mTitle   title
     */
    public static void loadUrl(Context mContext, String mUrl, String mTitle) {
        Intent intent = new Intent(mContext, WebViewActivity.class);
        intent.putExtra("mUrl", mUrl);
        intent.putExtra("mTitle", mTitle);
        mContext.startActivity(intent);
    }
}
